import request from '@/utils/request'

// 增
export function add(data) {
  return request({
    url: '/contract/add',
    method: 'post',
    data
  })
}

// 查
export function pageList(data) {
  return request({
    url: '/contract/pageList?pageNum='+data.pageNum+"&pageSize="+data.pageSize,
    method: 'post',
    data
  })
}

// 根据id查询
export function getById(id) {
  return request({
    url: '/contract/getById/' + id,
    method: 'get',
  })
}

// 改
export function updateById(data) {
  return request({
    url: '/contract/updateById',
    method: 'post',
    data
  })
}

// 删
export function deleteById(id) {
  return request({
    url: '/contract/deleteById/' + id,
    method: 'post',
  })
}
//审核合同
export function approvalState(data) {
  return request({
    url: '/approval/approvalState',
    method: 'post',
    data
  })
}
//作废合同
export function cancelContract(id) {
  return request({
    url: '/contract/cancelContract/'+id,
    method: 'post',
  })
}
//电子合同提交审核
export function comitApproval(id) {
  return request({
    url: '/contract/comitApproval/'+id,
    method: 'post',
  })
}

// 根据合同查询产品
export function getByContract(id) {
  return request({
    url: '/tourProduct/getByContract/'+id,
    method: 'get',
  })
}

export function htmlTopdf(data) {
  return new Promise((resolve, reject) => {
    // request对象是对axios的封装，不用在意
    request({
      url: '/contract/htmlToPdf',
      method: 'post',
      data
    }).then(ret => {
      resolve(ret.data)
    })
  })
}


export function getTravelPlan(id) {
  return request({
    url: '/travelPlan/pageList',
    method: 'post',
    data: {
      conId: id
    }
  })
}
//查询合同所有信息
export function getAllInfo(id) {
  return request({
    url: '/contract/getAllInfo/'+id,
    method: 'get',
  })
}
